<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //1.模拟私有的属性和方法 约定俗成： _开头表示私有
    //2. 将私有属性和方法移除类
    (function(){
      let name=''
      function setName(){
        name='llj'
      }
      class Person{
        constructor(username){
          name=username
        }
        getName(){
          return name
        }
      }
      window.Person=Person
    })()
    const p=new Person('a')
    console.log(p.name);
  </script>
</body>
</html>